<template>
    <div v-show="infoShow">
        <el-card class="box-card" shadow="never">
            <div class="header-view">
                <div class="header-left">
                    <div class="title-icon"></div>
                    <span>车辆信息</span>
                </div>

                <img
                    style="float: right; padding: 3px 0;cursor: pointer;height: 25px;width: 25px;"
                    src="/static/img/close_btn_icon.png"
                    @click="close">
            </div>
            <el-row>
                <el-row class="card-center">
                    <el-row>
                        <el-col :span="2">
                            <el-row type="flex" justify="center" align="middle">
                                <div class="license-plate-number"></div>
                            </el-row>
                        </el-col>
                        <el-col :span="5" class="left-text">
                            <el-row type="flex" justify="end">车 牌 号:</el-row>
                        </el-col>
                        <el-col :span="17" class="right-text">{{dataDetails.plateNo}}</el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="2">
                            <el-row type="flex" justify="center" align="middle">
                                <div class="sim"></div>
                            </el-row>
                        </el-col>
                        <el-col :span="5" class="left-text">
                            <el-row type="flex" justify="end">SIM卡号:</el-row>
                        </el-col>
                        <el-col :span="17" class="right-text">{{dataDetails.boxSimNo}}</el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="2">
                            <el-row type="flex" justify="center" align="middle">
                                <div class="company"></div>
                            </el-row>
                        </el-col>
                        <el-col :span="5" class="left-text">
                            <el-row type="flex" justify="end">管理单位:</el-row>
                        </el-col>
                        <el-col :span="17" class="right-text">{{dataDetails.enterpriseName}}</el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="2">
                            <el-row type="flex" justify="center" align="middle">
                                <div class="date-time"></div>
                            </el-row>
                        </el-col>
                        <el-col :span="5" class="left-text">
                            <el-row type="flex" justify="end">上传时间:</el-row>
                        </el-col>
                        <el-col :span="17" class="right-text">{{dataDetails.update | moment("YYYY-MM-DD HH:mm:ss")}}</el-col>
                    </el-row>
                </el-row>
                <el-row v-show="false">
                    <el-col :span="8">
                        <el-button round @click="realTime">
                            实时轨迹
                        </el-button>
                    </el-col>
                    <el-col
                        :span="8">
                        <el-button round @click="history">
                            历史轨迹
                        </el-button>
                    </el-col>
                    <el-col
                        :span="8">
                        <el-button round type="primary" @click="showVideo">
                            实时视频
                        </el-button>
                    </el-col>
                </el-row>
            </el-row>
        </el-card>
    </div>
</template>

<script>
import {queryVehicleInfo} from '../../api/vehicle'

export default {
    name: "vehicleInfoWindow",
    data(){
        return{
            infoShow:false,
            uid:null,
            dataDetails:{}
        }
    },
    methods:{
        close(){
            this.infoShow = false
        },
        open(data){
            this.uid = data.uid
            this.infoShow = true
            this.getDetails()
        },
        getDetails(){
            const param = {
                uid:this.uid
            }
            queryVehicleInfo(param).then(response => {
                console.log(response)
                this.dataDetails = response.data.data
            }).catch(error => {
                console.log(error)
            })
        },
        realTime(){
            this.$emit('onRealTimeClick',this.dataDetails)
            this.close()
        },
        history(){
            this.$emit('onHistoryClick',this.dataDetails)
            this.close()
        },
        showVideo(){
            this.$emit('showVideo',this.dataDetails)
            this.close()
        }
    }
}
</script>

<style scoped lang="scss">
.text {
    font-size: 14px;
}

.item {
    margin-bottom: 18px;
}

.clearfix:before,
.clearfix:after {
    display: table;
    content: "";
}
.clearfix:after {
    clear: both
}

.box-card {
    width: 400px;
    z-index: 999;
}

.el-row {
    margin-bottom: 20px;
    &:last-child {
        margin-bottom: 0;
    }
}

.header-view{
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;

    .header-left{
        width: 100%;
        flex: 1;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        font-size: 20px;
        font-weight: bold;
        color: #000000;
        .title-icon{
            width: 25px;
            height: 25px;
            background: url("/static/img/car_title_icon.png");
            background-size: 100% 100%;
            margin-right: 10px;
        }
    }

}

.card-center{
    background:#F7FBFF;
    padding-top: 20px;
    padding-bottom: 30px;
    margin-top: 20px;
    margin-bottom: 30px;
}

.left-text{
    font-size: 15px;
    color: #000000;
    font-weight: bold;
}

.right-text{
    font-size: 15px;
    color: #797878;
    font-weight: bold;
    padding-left: 5px;
}


.license-plate-number{
    background: url("/static/img/license_plate_number_icon.png");
    width: 15px;
    height: 15px;
    background-size: 100% 100%;
}

.sim{
    background: url("/static/img/sim_icon.png");
    width: 15px;
    height: 15px;
    background-size: 100% 100%;
}

.company{
    background: url("/static/img/company_icon.png");
    width: 15px;
    height: 15px;
    background-size: 100% 100%;
}

.date-time{
    background: url("/static/img/date_time_icon.png");
    width: 15px;
    height: 15px;
    background-size: 100% 100%;
}

</style>
